import path from 'node:path'
import fs from 'fs-extra'

export const PKG_PLUGIN = 'unplugin-uni-router'
export const PKG_NAME = 'uniapp-router-next'
export const RELEASE_TYPES = ['patch', 'minor', 'major']
export const PRE_RELEASE = 'prerelease'
export const PRE_RELEASE_TYPES = ['alpha', 'beta', 'rc']

export const proRoot = process.cwd()

export const pkgRoot = path.resolve(proRoot, 'packages')

export const proPkg = path.resolve(proRoot, 'package.json')

export const packages = (() => {
  const targetsDir = fs.readdirSync(pkgRoot)
  return targetsDir
    .map((dir) => path.resolve(pkgRoot, dir))
    .filter((path) => fs.statSync(path).isDirectory())
})()
